package day10stringbuilderdemo;

import java.util.Scanner;

public class StringBuilderDemo4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串");
        String str = sc.next();
        //使用 StringBuilder 的场景
        //字符串的拼接
        //字符串的反转



        //反转 赋值  比较  链式编程思路
        String s = new StringBuilder(str).reverse().toString();
        if (s.equals(str)) {
            System.out.println("是对称字符串");
        } else {
            System.out.println("不是对称字符串");
        }




        /*boolean flag = flag(str);
        if (flag){
            System.out.println("是对称字符串");
        }else {
            System.out.println("不是对称字符串");
        }*/


    }
     //双指针
    /*public static boolean flag(String str) {
        for (int i = 0, j = str.length()-1; i <= j; i++, j--) {
            char c1 = str.charAt(i);
            char c2 = str.charAt(j);
            if (c1 == c2) {
                return true;
            } else {
                System.out.println("");
                break;
            }
        }
        return false;

    }*/


}
